<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <p>{{inputText}}</p>
        请输入：<input v-model="inputText">

    </div>
    <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.0/vue.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/element-ui/2.15.3/index.js"></script>
    <script>
        const app = new Vue({
            el: '#app',
            data() {
                return {
                    inputText: window.localStorage.getItem('inputText')
                }
            },
            watch: {
                inputText: {
                    deep: true,
                    handler: function (value) {
                        window.localStorage.setItem('inputText', value)
                    }
                }
            }
        });
    </script>
</body>

</html>